Updated for 2.6.1 by: The Tech Support Team, Pictorius Incorporated
Contents: Drag Item.pgs
Drag Item.ReadMe
CopyPix.XDEF
CopyPix XDEF • Read me
Needs Prograph Extensions:
The default configuration of your 'Prograph Extensions' folder. Plus the CopyPix.XDEF should be added to your Prograph Extensions folder and all externals rebuilt.
Needs Libraries to Compile:
SCLibrary 2.6
Library 2.6
Standard Methods That Were Modified:
None
Using the Drag Item class
-----------------------
It is a good idea to create and use a sub-class of Drag Item for your draggable objects. Overshadow the methods of Drag Item, rather than editing them ( ie create methods of the same names in your sub-class ).
Overshadowing Methods
---------------------
There are four routines in the Drag Item class that can be overshadowed. They are used as follows:
Update
------
This method draws the Drag Item, and MUST be overshadowed. You
should put your draw code here. If you use the "location" attribute of the Drag Item in this routine, be sure to use the overriding get method. Otherwise, your drawing will not be performed correctly.
click
-----
This is the method that is called when a click occurs in a Drag Item. The first thing you should do in your click method is call "//drag". This method will fail if the click is not a drag, allowing you to process non drag clicks.
hit?
----
This method is used to determine if a click is actually within the
bounds of your object. Overshadow it if you do not want the entire rect of the Drag Item to respond to dragging. Your method should succeed or fail accordingly.
limit
-----
This method returns the rect within which the Drag Item may be
dragged. The default value is the entire window rect. Overshadow it if you wish to limit dragging to a rect within the window.
Memory Considerations
---------------------
Dragging a Drag Item uses two Pixmaps. One is the size of the
window; the other is the size of the Drag Item. In order to be as flexible as possible, the Drag Item class allocates these PixMaps dynamically as they are needed. Thus, each time a drag begins, two PixMaps are allocated and then disposed of when the drag is finished.
The advantage of this approach is that changes in the size or depth of the window or the size of the Drag Item require no special consideration.
The disadvantage is that, depending on the amount of memory
available and the state it is in, the allocation process this can cause a slight delay before the Drag Item will respond to the drag and follow the mouse.
If you wish to avoid this pause, you can modify the code to allocate one or both of the PixMaps at startup, and use them repeatedly. In this case, any changes in the window size or depth, or any change in the size of the object(s) being dragged will necessitate the re-allocation of one or both PixMaps.
General Notes
-------------
Be careful with the "location" attribute. Always use the
overshadowed get and set methods for it. If you explicitly set it in the Application Builder or directly in the instance, be sure to set the "drag loc" attribute to the same value. Otherwise, subsequent drawing of the Drag Item will be incorrect.
To avoid flickering of Window Items caused by redrawing after a
drag, both the old and new positions of the Drag Item are validated ( This is done in the "after" local of the drag routine ). The drag routine performs the update explicitly. However, Window Items such as Buttons ( or any other control ) cannot be updated by the drag routine. If you have such items residing within your drag limits, you may wish to modify the code to allow them to be updated. This will cause some flickering, but is necessary to allow such items to be properly redrawn.